




#import "NavigationController.h"

@interface NavigationController ()

@end

@implementation NavigationController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    //导航栏背景颜色
    [self.navigationBar setBarTintColor:Color_333333];
    [self.navigationBar setTranslucent:NO];
    //导航栏背景图片
    //    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"first01"] forBarMetrics:UIBarMetricsDefault];
    //导航栏字体颜色 PingFangSC-Medium    Arial-BoldItalicMT
    [[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Arial-BoldItalicMT" size:19.f],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
//    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:16]}];

    if ([self.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics: )]) {//设置返回按钮样式。这里是自定义的图片
        UIImage *image = [UIImage imageNamed:@"导航栏_返回"];
        image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        self.navigationBar.backIndicatorImage = image;
        self.navigationBar.backIndicatorTransitionMaskImage = image;
//        [self.NavigationBar setTintColor:RGB(58, 58, 58)];

    }
    
    /* 这个方法是设置导航栏背景颜色，状态栏也会随之变色 */
    UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
    if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
        statusBar.backgroundColor = Color_333333;
    }

}
- (void)viewDidLoad {
    [super viewDidLoad];
    
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    //修改掉返回按钮的文本
    viewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@" " style:UIBarButtonItemStyleDone target:nil action:nil];
    //判断第二级界面是否显示下边标签栏
    if (self.childViewControllers.count>0) {
        viewController.hidesBottomBarWhenPushed=YES;
    }
    //如果当前是正在pop的过程，就禁止左边缘右划手势
    if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.interactivePopGestureRecognizer.enabled = NO;
    }
    [super pushViewController:viewController animated:animated];
}
//+(void)initialize
//{
//    UINavigationBar *NavigationBar = [UINavigationBar appearanceWhenContainedIn:self, nil];
//    [NavigationBar setBackIndicatorImage:[UIImage imageNamed:@"导航栏_返回"]];
//    [NavigationBar setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"导航栏_返回"]];
//    [NavigationBar setTintColor:RGB(58, 58, 58)];
//}

@end
